package com.tangding;
import java.io.IOException;
import java.net.URISyntaxException;

import org.apache.tomcat.jni.Thread;

import hprose.client.HproseTcpClient;
import hprose.common.HproseCallback1;

public class TCPHelloClient2 {
    public interface IStub {
//        @SimpleMode(true)
        String Hello(String name);
//        @SimpleMode(true)
        void Hello(String name, HproseCallback1<String> callback);
    }
    
    
    public static void main(String[] args) throws IOException, URISyntaxException {
        final HproseTcpClient client = new HproseTcpClient("tcp://127.0.0.1:4321/");
        client.setFullDuplex(true);
        client.setMaxPoolSize(1);
        /*IStub stub = client.useService(IStub.class);
        stub.Hello("Async World", new HproseCallback1<String>() {
            public void handler(String result) {
                System.out.println(result);
            }
        });
        stub.Hello("Async World2", new HproseCallback1<String>() {
            public void handler(String result) {
                System.out.println(result);
            }
        });
        stub.Hello("Async World3", new HproseCallback1<String>() {
            public void handler(String result) {
                System.out.println(result);
            }
        });
        stub.Hello("Async World4", new HproseCallback1<String>() {
            public void handler(String result) {
                System.out.println(result);
            }
        });
        stub.Hello("Async World5", new HproseCallback1<String>() {
            public void handler(String result) {
                System.out.println(result);
            }
        });
        System.out.println(stub.Hello("World"));
        System.out.println(stub.Hello("World2"));
        System.out.println(stub.Hello("World3"));
        System.out.println(stub.Hello("World4"));
        System.out.println(stub.Hello("World5"));*/
        
        new java.lang.Thread(new Runnable() {
			public void run() {
				try {
					Object result = client.invoke("hello", new Object[] {"World" + 100});
					System.out.println(result);
				} catch (Throwable e) {
					e.printStackTrace();
				}
		        client.close();
			}
		}).start();
    }
}